using ELS.Components;
using ELS.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MudBlazor;
using MudBlazor.Services;

namespace ELS
{
	public class Program
	{
		public static async Task Main(string[] args)
		{
			var builder = WebApplication.CreateBuilder(args);

			// Add MudBlazor services
			builder.Services.AddMudServices(config =>
			{
				config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.TopRight;
				config.SnackbarConfiguration.PreventDuplicates = false;
				config.SnackbarConfiguration.NewestOnTop = true;
				config.SnackbarConfiguration.ShowCloseIcon = true;
				config.SnackbarConfiguration.VisibleStateDuration = 3000;
				config.SnackbarConfiguration.HideTransitionDuration = 300;
				config.SnackbarConfiguration.ShowTransitionDuration = 300;
				config.SnackbarConfiguration.SnackbarVariant = Variant.Filled;
			});

			// Add services to the container.
			builder.Services.AddRazorComponents()
			.AddInteractiveServerComponents();

			builder.Services.AddScoped<IAccountService, AccountService>();
			builder.Services.AddScoped<ISqliteDataService, SqliteDataService>();
			builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();

			var app = builder.Build();

			// Configure the HTTP request pipeline.
			if (!app.Environment.IsDevelopment())
			{
				app.UseExceptionHandler("/Error");
				// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
				app.UseHsts();
			}

			app.UseHttpsRedirection();

			app.UseStaticFiles();
			app.UseAntiforgery();

			app.MapRazorComponents<App>()
				.AddInteractiveServerRenderMode();

			await app.RunAsync();
		}
	}
}
